import json
import unittest

from parameterized import parameterized

from login import login


def login_1():
    with open('login_data.json', encoding='utf-8') as f:
        result = json.load(f)
        data = []
        for i in result:
            data.append((i.get('username'), i.get('password'), i.get('expect')))
    return data


class TestDemo(unittest.TestCase):
    def setUp(self):
        print("打开网页")

    def tearDown(self):
        print("关闭网页")

    @classmethod
    def setUpClass(cls):
        print("打开浏览器")

    @classmethod
    def tearDownClass(cls):
        print("关闭浏览器")

    @parameterized.expand(login_1())
    def test_case1(self, username, password, expect):
        self.assertEqual(expect, login(username, password))

